from __future__ import annotations

from litestar.params import Parameter
from litestar.repository.filters import LimitOffset


async def provide_limit_offset_pagination(
    page: int = Parameter(query="page", ge=1, default=1, required=False),
    size: int = Parameter(query="size", ge=1, default=10, required=False),
) -> LimitOffset:
    """Add offset/limit pagination.

    Return type consumed by `Repository.apply_limit_offset_pagination()`.

    Parameters
    ----------
    page : int
        limit to apply to select.
    size : int
        offset to apply to select.
    """
    return LimitOffset(size, size * (page - 1))
